package com.car.carmgr.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class AjaxResult implements Serializable {
    private Integer code;
    private String msg;
    private Integer count;
    private Object data;


    public static AjaxResult ok(Object data){
        return new AjaxResult(0,"ok",0,data);
    }

    public static AjaxResult ok(Integer count ,Object data){
        return new AjaxResult(0,"ok",count,data);
    }

    public static AjaxResult error(Integer code , String msg){
        return new AjaxResult(code,msg,0,null);
    }

    public static AjaxResult ADD_SUCCESS(){
        return new AjaxResult(0,"添加成功",0,null);
    }
    public static AjaxResult ADD_FAILED(){
        return new AjaxResult(-1,"添加失败",0,null);
    }

    public static AjaxResult UPD_SUCCESS(){
        return new AjaxResult(0,"修改成功",0,null);
    }
    public static AjaxResult UPD_FAILED(){
        return new AjaxResult(-1,"修改失败",0,null);
    }

    public static AjaxResult FIND_SUCCESS(){
        return new AjaxResult(0,"查找成功",0,null);
    }
    public static AjaxResult FIND_FAILED(){
        return new AjaxResult(-1,"未找到该客户",0,null);
    }

    public static AjaxResult ALLOTROLE_SUCCESS(){
        return new AjaxResult(0,"分配角色成功",0,null);
    }
    public static AjaxResult ALLOTROLE_FAILED(){
        return new AjaxResult(-1,"未找到该客户",0,null);
    }

    public static AjaxResult RESETPWD_SUCCESS(){
        return new AjaxResult(0,"重置密码成功",0,null);
    }
    public static AjaxResult RESETPWD_FAILED(){
        return new AjaxResult(-1,"重置密码失败",0,null);
    }

    public static AjaxResult DEL_SUCCESS(){
        return new AjaxResult(0,"删除成功",0,null);
    }
    public static AjaxResult DEL_FAILED(){
        return new AjaxResult(-1,"删除失败",0,null);
    }

    public static AjaxResult DELSOME_SUCCESS(){
        return new AjaxResult(0,"批量删除成功",0,null);
    }
    public static AjaxResult DELSOME_FAILED(){
        return new AjaxResult(-1,"批量删除失败",0,null);
    }

    public static AjaxResult DEL_HAS_CH(){
        return new AjaxResult(-1,"该菜单有子菜单，不能删除",0,null);
    }
}
